package jt.android.platformania;

import jt.android.platformania.api.GameView;
import jt.android.platformania.api.SoundManager;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Window;

/// Main android activity, runs when the application is launched
public class GameActivity extends Activity 
{
	private GameView gameView;
	private SoundManager soundManager;
	private String tag;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        tag = "GameActivity";
    	Log.d(tag, "Activity onCreate() called");

        // Turn off the window's title bar
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        
        // Use XML layout -- this also instantiates some things.
        setContentView(R.layout.main);
        
        // GameView is instantiated from XML, so lets grab it that way
        gameView = (GameView)findViewById(R.id.gameView);
        
        // Initialize the sound manager
        soundManager = new SoundManager(this);
        
        // Pass the sound manager message queue to the game thread
        gameView.getGameThread().registerSoundHandler(soundManager.getHandler());
    }
    
    @Override
    public void onStart()
    {
    	super.onStart();
    	Log.d(tag, "onStart() called");
    }
    
    @Override
    public void onResume()
    {
    	super.onResume();
    	Log.d(tag, "onResume() called");
    }
    
    @Override
    public void onPause()
    {
    	super.onPause();
    	Log.d(tag, "onPause() called");
    }
    
    @Override
    public void onStop()
    {
    	super.onStop();
    	Log.d(tag, "onStop() called");
    }
    
    @Override
    public void onDestroy()
    {
    	super.onDestroy();
    	Log.d(tag, "onDestroy() called");
    }
    
    @Override
    public void onRestart()
    {
    	super.onRestart();
    	Log.d(tag, "onRestart() called");
    }
}